package com.hsylient.redis.mapper;

import cn.hutool.core.collection.CollUtil;
import com.hsylient.common.entity.User;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public class UserMapper {

    /**
     * 这里模拟从数据库里边查出来的数据
     *
     * @return 来自数据库中的数据
     */
    public List<User> selectFormDb() {
        User user = new User();
        user.setId(1L);
        user.setName("hsylient");
        user.setAge(18);
        user.setAddress("河南");
        user.setSalary(BigDecimal.valueOf(99999.99));
        User user2 = new User();
        user2.setId(2L);
        user2.setName("郑浩");
        user2.setAge(19);
        user2.setAddress("安徽");
        user2.setSalary(BigDecimal.valueOf(88888.88));
        User user3 = new User();
        user3.setId(3L);
        user3.setName("孟令坤");
        user3.setAge(21);
        user3.setAddress("芜湖");
        user3.setSalary(BigDecimal.valueOf(77777.777));
        return CollUtil.newArrayList(user2, user, user3);
    }

    /**
     * 模拟通过Id查询
     *
     * @param userId 用户ID
     * @return 查询结果
     */
    public User selectByUserId(Long userId) {
        User user = new User();
        user.setId(userId);
        user.setName("孟令坤");
        user.setAge(21);
        user.setAddress("芜湖");
        user.setSalary(BigDecimal.valueOf(66666.666));
        return user;
    }
}
